home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0040_Sound with Keys.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  640b  |  40 lines

  1. {
  2. TOM MOORE
  3.  
  4. > In a PASCAL-Program I want to execute a Procedure every time the
  5. > user presses a key... Fairly easy, right ? But here comes the
  6. > problem : I want to Repeat that Procedure Until he RELEASES that
  7. > key...
  8. }
  9.  
  10. Uses
  11.   Crt;
  12. Const
  13.   Done : Boolean = False;
  14. Var
  15.   Ch : Char;
  16.  
  17.  
  18. Procedure MakeSound;
  19. begin
  20.   if Port[$60] < $80 then
  21.   begin
  22.     Sound(220);
  23.     Delay(100);
  24.   end;
  25.   if port[$60] >  $80 then
  26.     NoSound;
  27. end;
  28.  
  29. begin
  30.   Repeat
  31.     Repeat
  32.     { While waiting For KeyPressed }
  33.     Until KeyPressed;
  34.  
  35.     ch := ReadKey;
  36.     if ch = #27 then halt;
  37.       makeSound;
  38.   Until Done;
  39. end.
  40.